package com.cn.gxa.springmongo.controller;

import com.cn.gxa.springmongo.pojo.Post;
import com.cn.gxa.springmongo.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PostController {

    @Autowired
    private PostService  postService;


    @GetMapping("/add")
    public  String add(Post post){
          postService.add(post);
          return  "success";
    }

    @GetMapping("/del")
    public  String del(Integer no){
        postService.delById(no);
        return  "success";
    }

    @GetMapping("/_del/{id}")
    public  String delId(@PathVariable("id") String id){
        postService.delBy_id(id+"");
        return  "success";
    }

    @GetMapping("/findUserId")
    public  String findByUserId(Integer  userId){
        postService.findByUserId(userId);
        return  "success";
    }

    @GetMapping("/update")
    public  String update(Post post){
        postService.update(post);
        return  "success";
    }


}
